<div class="logged-in">
  <div class="container center-column">
    <ul class="subnav right">
      <li><%= link_to current_user.full_name, cms.edit_user_path(current_user) unless current_user.guest? %></li>
      <li><%= link_to "Settings", "#" unless current_user.guest? %></li>
      <li><%= link_to "Help", 'https://github.com/browsermedia/browsercms/wiki', target: '_blank' %></li>
      <li><%= link_to "Logout", cms.logout_path unless current_user.guest? %></li>
    </ul>
  </div>
</div>

<div class="primary-nav">
  <div class="container center-column">
    <%= link_to image_tag('cms/logo.png', class: 'main-logo'), "/" %>
    <ul class="mainnav">
      <% if current_user.able_to?(:edit_content) %>
      <li>
        <%= link_to "Dashboard", cms.dashboard_path %>
        <ul class="dropdown-menu">
        </ul>
      </li>
      <li>
        <%= link_to "Pages", cms.sitemap_path %>
      </li>
      <li>

        <a href="#"
           class="dropdown-toggle"
           data-toggle="dropdown">
          Assets
          <b class="caret"></b>
        </a>
        <%= render partial: 'layouts/cms/content_types', locals: { library: true, id: 'content-library-menu' } %>
      </li>
      <% end %>
      <% if current_user.able_to? :administrate %>
      <li>
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin<b class="caret"></b></a>
        <ul class="dropdown-menu">
          <%= nav_link_to "Users", cms.users_path %>
          <%= nav_link_to "Groups", cms.groups_path %>
          <%= divider_tag %>
          <%= nav_link_to "Partials", cms.page_partials_path %>
          <%= nav_link_to "Page Templates", cms.page_templates_path %>
          <%= divider_tag %>
          <%= nav_link_to "Redirects", cms.redirects_path %>
          <%= nav_link_to "Routes", cms.page_routes_path %>
          <%= nav_link_to "Page Cache", cms.cache_path %>
          <%= nav_link_to "Email Messages", cms.email_messages_path %>
          <% Rails.application.config.cms.tools_menu.each do |menu_item| %>
              <%= nav_link_to(menu_item[:name], self.send(menu_item[:engine]).send(menu_item[:route_name])) %>
          <% end %>
        </ul>
      </li>
      <% end %>
    </ul>

    <% if current_user.able_to?(:edit_content) %>
    <div class="btn-group">
      <%= menu_button "New", new_button_path, id: 'new-content-button', class: 'btn btn-primary', tabindex: '-1' %>
      <button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" tabindex="-1">
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu pull-right">
        <%= render 'cms/toolbar/new_pages_menu' %>
        <% modules = Cms::ContentType.available_by_module
           modules.keys.compact.sort.each_with_index do |module_name, i| %>
            <%= divider_tag(i) %>
            <% modules[module_name].each do |type| %>
                <%= nav_link_to h(type.display_name), new_engine_aware_path(type), id: "create_new_#{type.param_key}" %>
            <% end -%>
        <% end %>
      </ul>

    </div>
    <% end %>
  </div>
</div>
